<%--
  @author Tharanga Punchihewa
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<script type="text/javascript">
    $(document).ready(function() {
        $('.data-table').dataTable({
            "oTableTools": {
                "aButtons": [
                    {
                        "sExtends": "print",
                        "bShowAll": true
                    }
                ]
            }
        });
    });
</script>

<div id="land-registration-module-home" class="module-home">
</div>
<div id="land-registration-module-home-title" class="module-home-title">
    <%--<s:a href="landInterests.do"><img src="${pageContext.request.contextPath}/images/land-reg.png"
                                             alt="Land Registration"><span><s:label
            value="Land Interests"/></span></s:a>--%>
    <s:if test="user.role.id=='ORPII'">
        <s:a href="organizationUserManagementHome.do"><img src="${pageContext.request.contextPath}/images/user.png"
                                                                  alt="User Module"><span><s:label
                value="%{getText('user_module.label')}"/></span></s:a>
        <span class="module-title-breaker"> > </span>
        <s:a href="#"><img src="${pageContext.request.contextPath}/images/accept.png"
                           alt="User Module"><span><s:label
                value="%{getText('approve_urmgoi_user_account.label')}"/></span></s:a>
    </s:if>
</div>
<s:if test="pageMode==5">
    <div class="page-title">
        <h2><s:label value="%{getText('edit_users.label')}"/></h2>
    </div>
</s:if>
<s:elseif test="pageMode==6">
    <div class="page-title">
        <h2><s:label value="%{getText('active_inactive_users.label')}"/></h2>
    </div>
</s:elseif>
<s:elseif test="user.role.id=='ORPII'">
    <div class="page-title">
        <h2><s:label value="%{getText('approve_urmgoi_user_account.label')}"/></h2>
    </div>
</s:elseif>
<s:if test="hasActionErrors() || hasActionMessages()">
    <div id="message-box" class="message-box">
        <div class="action-msg"><s:actionmessage/></div>
        <div class="action-err"><s:actionerror/></div>
    </div>
</s:if>
<table class="width-100 margin-10-auto table data-table" id="ORPII-user-list">
    <thead>
    <tr class="center-align table-header">
        <th class="width-450-px"><s:label value="%{getText('full_name.label')}"/></th>
        <s:if test="user.role.id=='ORPII'">
            <th><s:label value="%{getText('active.label')}"/></th>
        </s:if>
        <s:elseif test="user.role.id=='ORMOI'">
            <s:if test="pageMode==5">
                <th><s:label value="%{getText('edit.label')}"/></th>
            </s:if>
            <s:if test="pageMode==6">
                <th><s:label value="%{getText('active.label')}"/></th>
            </s:if>

        </s:elseif>

    </tr>
    </thead>
    <tbody>
    <s:iterator status="status1" value="usersList">
        <tr>
            <td class="center-align">
                <s:property value="fullName"/>
            </td>
            <s:if test="user.role.id =='ORMOI'">
                <s:if test="pageMode==5">
                    <td class="center-align">
                        <s:url id="initEditORPIIUserInfo" action="initEditORPIIUserInfo">
                            <s:param name="orpiiUserId" value="username"/>
                            <s:param name="organizationId"/>
                        </s:url>
                        <s:a href="%{initEditORPIIUserInfo}">
                            <img src="<s:url value='/images/modify-form.png'/>" class="image-icon" title="Edit"/>
                        </s:a>

                    </td>
                </s:if>
                <s:if test="pageMode==6">
                    <td class="center-align">
                            <%--If the ORPII User is inactive ORMOI can active ORPII--%>
                        <s:if test="status.ordinal()== 0">
                            <s:url id="activeORPIIUser" action="activeORPIIUser">
                                <s:param name="orpiiUserId" value="username"/>
                                <s:param name="organizationId" value="organization.id"/>
                            </s:url>
                            <s:a href="%{activeORPIIUser}">
                                <img src="<s:url value='/images/approve.png'/>" class="image-icon" title="Active"/>
                            </s:a>
                        </s:if>

                            <%--If the ORPII User is active ORMOI can inactive ORPII--%>
                        <s:if test="status.ordinal()== 1">
                            <s:url id="inactiveORPIIUser" action="inactiveORPIIUser">
                                <s:param name="orpiiUserId" value="username"/>
                                <s:param name="organizationId" value="organization.id"/>
                            </s:url>
                            <s:a href="%{inactiveORPIIUser}">
                                <img src="<s:url value='/images/reject.png'/>" class="image-icon" title="Inactive"/>
                            </s:a>
                        </s:if>

                    </td>
                </s:if>
            </s:if>
            <s:elseif test="user.role.id=='ORPII'">
                <td class="center-align">
                    <s:url id="activeURMGOIUserAccount" action="activeURMGOIUserAccount">
                        <s:param name="orpiiUserId" value="username"/>
                    </s:url>
                    <s:a href="%{activeURMGOIUserAccount}">
                        <img src="<s:url value='/images/approve.png'/>" class="image-icon" title="Approve"/>
                    </s:a>
                </td>
            </s:elseif>

        </tr>
    </s:iterator>
    </tbody>
</table>